package com.example.javabasic.thread.classtwo.future.demo2;

import java.util.LinkedList;

//通知队列
public class RequestQueue {
    //结果集队列
    private final LinkedList<Request> queue = new LinkedList<>();

    public Request getRequest(){
        synchronized (queue){
            while(queue.size()<=0){
                try {
                    queue.wait();
                } catch (InterruptedException e) {
                    return null;
                }
            }
            return queue.removeFirst();
        }
    }

    public void setRequest(Request request){
        synchronized (queue){
            queue.addLast(request);
            queue.notifyAll();
        }

    }
}
